import {observable} from 'mobx';
import {Tools,Bubble} from 'weaver-mobile';
import { RouteLayout,ListPage } from 'weaver-mobile-page';
import * as API from '../../api/application/index';

const getLabel = Tools.getLabel;

export default class ApplicationStore {
    /********************************************************/
    @observable loading = false;
    @observable hasRight = false;

    @observable datas = [];
    @observable assistantData = new ListPage.Store();
    @observable incoicesRoute = new RouteLayout.Store({id:'details', route:`/invoiceAssistant`})
    @observable info = {};
    @observable billDetails = {};
    @observable docid = ''; //附件id
    @observable imagefileid = ''; //文档Id


    //获取应用 图标
    getThreePartiesAll = (value={}) =>{
        this.loading = true;
        API.getThreePartiesAll(value).then(res =>{
            const {status,errorInfo} = res;
            if(status === '1'){
                this.datas = res.threeParties;
                this.docid = res.docid;
                this.imagefileid = res.imagefileid;
            }else{
                Bubble.error(errorInfo)
            }
            this.loading = false;
        })

    }

    //开票助手 list
    getbillingAssistantList = (value={}) =>{
        this.loading = true;
        API.getbillingAssistantList(value).then(res =>{
            const {status,errorInfo,assistantData} = res;
            if(status === '1'){
                if(assistantData){
                    this.assistantData.setState(assistantData);
                }else{
                    this.assistantData = new ListPage.Store();
                }
                
            }else{
                Bubble.error(errorInfo)
            }
            this.loading = false;
        })
    }

    //开票助手查看页面 详情
    getbillingAssistantSetPage = (value={}) =>{
        this.loading = true;
        API.getbillingAssistantSetPage(value).then(res =>{
            const {status,errorInfo,billDetails} = res;
            if(status === '1'){
               this.billDetails = billDetails;
            }else{
                Bubble.error(errorInfo)
            }
            this.loading = false;
        })
    }

    setInfo = (value) =>{
        this.info = value;
    }
    


}